<?php
	require_once ("../../config.inc.php");
	require_once ("../../include/mysql.inc.php");
	require_once ("../../include/feed.inc.php");
	
	$email = $_POST("email");
	$dom = new DOMDocument("1.0","UTF-8");
	$result = '';
	if ((! empty($email)) && (ltrim($email) != '')) {//邮箱不为空
		$feedDao = new Feed();
		if ($feedDao->add($email) && true) {//并且发送邮件成功
			$result = $dom->createElement("result", 1);//成功订阅，需要验证
		}
		else {
			$result = $dom->createElement("result", -1);//邮箱错误
		}
	}
	else {
		$result = $dom->createElement("result", 0);//邮箱为空
	}
	
	$dom->appendChild($result);
	header("Content-type:text/xml");
	$xmlfile = $dom->saveXML();
	file_put_contents("../../xml_data/feedAdd.xml",$xmlfile);
	echo $xmlfile;
	
?>